package com.kairos.jetparksample.domain

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

/**
 *@Author Nick.wu
 *Date 2023/6/13
 *
 * 重点，ViewModel中不可以有视图层的引用，比如（Activity对象）
 * 可以使用Application作用域的，AndroidViewModel
 */
class ViewModelSample : ViewModel() {


    private val userInfoLiveData: MutableLiveData<User> by lazy {
        MutableLiveData<User>()
    }

    //对外暴露，访问只读
    val userInfo: LiveData<User>
        get() = userInfoLiveData

    fun requestSampleData() {
        userInfoLiveData.value = User(
            "不能用真名",
            "10086",
            wx = "已绑定"
        )
        //工作线程
        //userInfoModel.userInfo.postValue()
    }
}